﻿@{
    ViewBag.Title = "Form";
    Layout = "~/Views/Shared/_Form.cshtml";
}
<script type="text/javascript">
    var parentId = request('parentId');
    var moduleButtonId = request('moduleButtonId');
    var moduleId = request('moduleId');
    $(function () {
        initControl();
    })
    var dataJson = top.Form.buttonJson;
    //初始化控件
    function initControl() {
        //上级
        $("#F_ParentId").ComboBoxTree({
            url: "../../AuthorizeManage/ModuleButton/ListToTreeJson",
            param: { moduleButtonJson: JSON.stringify(dataJson) },
            method: "post",
            description: "==请选择==",
            height: "150px"
        });
        if (!!moduleButtonId) {
            $.each(dataJson, function (i) {
                var row = dataJson[i];
                if (row.F_ModuleButtonId == moduleButtonId) {
                    $("#form1").SetWebControls(row);
                }
            });
        } else {
            $("#F_ModuleId").val(moduleId);
            if (!!parentId) {
                $("#F_ParentId").ComboBoxTreeSetValue(parentId);
            } else {
                $("#F_ParentId").ComboBoxTreeSetValue(0);
            }
        }
    }
    //保存表单
    function AcceptClick(callback) {
        if (!$('#form1').Validform()) {
            return false;
        }
        var data = $("#form1").GetWebControls(moduleButtonId);
        if (data["F_ParentId"] == "") {
            data["F_ParentId"] = 0;
        }
        callback(data);
        dialogClose();
    }
</script>
<div style="margin-top: 10px; margin-right: 30px;">
    <input id="F_ModuleButtonId" type="hidden" value="@Guid.NewGuid().ToString()" />
    <input id="F_ModuleId" type="hidden" />
    <table class="form">
        <tr>
            <th class="formTitle">上级</th>
            <td class="formValue">
                <div id="F_ParentId" type="selectTree" class="ui-select">
                </div>
            </td>
        </tr>
        <tr>
            <th class="formTitle">编号<font face="宋体">*</font></th>
            <td class="formValue">
                <input id="F_EnCode" type="text" class="form-control" placeholder="请输入编号" isvalid="yes" checkexpession="NotNull" />
            </td>
        </tr>
        <tr>
            <th class="formTitle">名称<font face="宋体">*</font></th>
            <td class="formValue">
                <input id="F_FullName" type="text" class="form-control" placeholder="请输入名称" isvalid="yes" checkexpession="NotNull" />
            </td>
        </tr>
        <tr>
            <th class="formTitle">排序<font face="宋体">*</font></th>
            <td class="formValue">
                <input id="F_SortCode" type="text" class="form-control" placeholder="请输入排序" isvalid="yes" checkexpession="Num" />
            </td>
        </tr>
        <tr>
            <th class="formTitle">地址</th>
            <td class="formValue">
                <input id="F_ActionAddress" type="text" class="form-control" />
            </td>
        </tr>
    </table>
</div>

